import Vue from 'vue'
import VueRouter from 'vue-router'

// 方式1-标准写法
// import Login from '@/views/index.vue'

Vue.use(VueRouter)
const routes = [
  {
    path: '/',
    redirect: '/home',
    meta: { keepAlive: true },
    component: () => import('@/views/layout'),
    children: [{
      path: '/home',
      component: () => import('@/views/Home'),
      meta: { keepAlive: true }
    }, {
      path: '/qa',
      component: () => import('@/views/Qa')
    }, {
      path: '/video',
      component: () => import('@/views/Video')
    }, {
      path: '/my',
      component: () => import('@/views/My')
    }]
  },
  // { path: 'login', component: Login }
  // 方式2-简化写法,懒加载的写法
  { path: '/login', component: () => import('@/views/login') },
  { path: '/search', component: () => import('@/views/search') },
  {
    name: 'article',
    path: '/article/:articleId',
    component: () => import('@/views/article/index.vue'),
    props: true
  },
  { path: '/user/profile', component: () => import('@/views/user-profile') }

]

const router = new VueRouter({
  routes
})

export default router
